package Junit.SearchEngine;

import java.util.Iterator;
import java.util.Set;
import domain.items.Post;
import search.CompassSearchEngine;
import search.SearchDBManager;
import interfaces.SearchDataBase;
import interfaces.SearchEngine;
import junit.framework.TestCase;

public class CompassSearchEngineTest extends TestCase {
	SearchEngine _searchEngine;
	SearchDataBase _sdb;
	Post _post;
	
	protected void setUp() throws Exception {
		super.setUp();
		_searchEngine = CompassSearchEngine.getInstance();
		_sdb = new SearchDBManager();
		_post = new Post(null, "o1", "s1", "word");
	}
	public void testSearchByContent(){
		
		_sdb.addWordReference("word", _post);
		Set<Post> tWordSet = _sdb.getWordReference("word");
		assertEquals(1, tWordSet.size());
		Iterator<Post> tIt = tWordSet.iterator();
		assertEquals(_post, tIt.next());
	}
	
	public void testSearchByAuthor(){
		Set<Post> tSet =_sdb.getUserPosts("o1");
		assertEquals(1, tSet.size());
//		Iterator<Post> tIt = tSet.iterator();
//		assertEquals(_post, tIt.next());
		//		(CompassSearchEngine)_searchEngine.searchByAuthor(authorName)
	}
	

}
